<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * CodeIgniter
 *
 * An open source application development framework for PHP 5.1.6 or newer
 *
 * @package		CodeIgniter
 * @author		ExpressionEngine Dev Team
 * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc.
 * @license		http://codeigniter.com/user_guide/license.html
 * @link		http://codeigniter.com
 * @since		Version 1.0
 * @filesource
 */

// ------------------------------------------------------------------------

/**
 * Router Class
 *
 * Parses URIs and determines routing
 *
 * @package		CodeIgniter
 * @subpackage	Libraries
 * @author		ExpressionEngine Dev Team
 * @category	Libraries
 * @link		http://codeigniter.com/user_guide/general/routing.html
 */
class JD_Router extends CI_Router {

	/**
	 * Constructor
	 *
	 * Runs the route mapping function.
	 */
	function __construct()
	{
		parent::__construct();
	}
	
	function _validate_request($segments)
	{
		if (JD_ENABLE_PLUGIN === TRUE){
			$controller_name = count($segments) > 0 ? $segments[0] : $this->routes['default_controller'];
			$plugin_controller = jd_search_plugin_controller($controller_name);
			if ($plugin_controller !== FALSE){
				return $segments;
			}
		}
		return parent::_validate_request($segments);
	}
}